#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "PWM.h"
#include "Timer.h"
uint8_t i=0;
uint8_t state=0;
int main(void)
{
	PWM_Init();	
	Timer_Init();
	while(1)
	{
		
	}
}
void TIM3_IRQHandler(void)
{
	if (TIM_GetITStatus(TIM3, TIM_IT_Update) == SET)
    {
        // 每10ms直接更新i的值（替代LED_Tick的计数逻辑，更精准）
        switch(state)
        {
            case 0: i++; if(i >= 100) state = 1; break;
            case 1: i--; if(i == 0) state = 0; break;
        }
        PWM_SetComparel(i);  // 通过封装函数设置PWM占空比
        TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
    }
}